package com.neusoft.rental.service.impl;

import com.neusoft.rental.mapper.UserMapper;
import com.neusoft.rental.po.User;
import com.neusoft.rental.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    //根据学号，学校，密码查找用户
    @Override
    public User userQuery(User user){
        return userMapper.userQuery(user);
    }

    //用户注册时增加用户
    @Override
    public int userRegister(User user){
        return userMapper.userRegister(user);
    }

    //修改用户个人信息，判断一下，是在单独修改密码还是在修改个人信息
    @Override
    public int modifyInformation(User user) {
        if(user.getPasswd()!=null && user.getPasswd()!=""){
            User user1=userMapper.queryUserById(user.getUserid());
            user.setName(user1.getName());
            user.setSchool(user1.getSchool());
            user.setPhonenumber(user1.getPhonenumber());
        }
        return userMapper.modifyInformation(user);
    }
}
